package com.base.cn.platform.os.config;

import com.base.cn.platform.os.common.interceptor.BaseDataInterceptor;
import com.base.cn.platform.os.interceptor.SysAuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 应用配置
 * @author s.li
 * @create 2018-03-07 10:24
 */
@Configuration
public class AdminConfig implements WebMvcConfigurer {

    /**
     * 内容过滤器
     * @return
     */
    @Bean
    public BaseDataInterceptor baseDataInterceptor(){
        return new BaseDataInterceptor();
    }

    /**
     * 认证权限过滤器
     * @return
     */
    @Bean
    public SysAuthenticationInterceptor sysAuthenticationInterceptor(){
        return new SysAuthenticationInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(baseDataInterceptor()).addPathPatterns("/admin/**","/login","/register","/noAuthority","/notLoginJump");
        registry.addInterceptor(sysAuthenticationInterceptor()).addPathPatterns("/admin/**");
    }
}
